<template>
  <div>
    <el-card>
        <h1>
            添加用户
        </h1>
        <el-form >
          <el-form-item label="用户名">
            <el-input v-model="user.username" placeholder="请在此输入用户名"></el-input>
          </el-form-item>
          <el-form-item label="密码">
            <el-input v-model="user.password" placeholder="请在此输入密码" show-password></el-input>
          </el-form-item>
        </el-form>
        <el-button type="primary" @click="addUser">点击添加</el-button>
    </el-card>
  </div>
</template>

<script>
export default {
    data() {
        return {
            user:{
                username: '',
                password: '',
            }
        }
    },
    methods: {
        async addUser() {
            let result = await this.$API.user.addUser(this.user);
            if (result.code == 200) {
                this.$message({
                    message: "添加成功！",
                    type: "success",
                });

            } else {
                this.$message({
                    message: result.msg,
                    type: "error",
                });
            }
        }
    }
}
</script>

<style>

</style>